<template>
  <el-dialog title="" :visible.sync="successDialog" width="85%" append-to-body @close="closebtn1">
    <div class="refine_taskdetail">
      <div id="wordd">
        <div class="tit-cont">
          <div class="tit-div" style="margin-left:100px;">
            <div class="blue-div">
              <img src="@/assets/taskCreateBlue.png" v-if="form.createTime"/>
              <img src="@/assets/taskCreateG.png" v-else>
            </div>
            <p>{{form.createTime}}</p>
          </div>
          <div class="line-div">
            <p class="blue-line" v-if="form.sendTime"></p>
            <p class="grey-line" v-else></p>
          </div>
          <div class="tit-div margin25">
            <div class="blue-div">
              <img src="@/assets/taskUnitB.png" v-if="form.sendTime"/>
              <img src="@/assets/taskUnitG.png" v-else>
            </div>
            <p>{{form.sendTime}}</p>
          </div>
          <div class="line-div">
            <p class="blue-line" v-if="form.finishTime"></p>
            <p class="grey-line" v-else></p>
          </div>
          <div class="tit-div margin25">
            <div class="blue-div">
              <img src="@/assets/taskedB.png" v-if="form.finishTime">
              <img src="@/assets/taskedG.png" v-else>
            </div>
            <p>{{form.finishTime}}</p>
          </div>
        </div>
        <div class="task-detail">
          <ul>
            <li class="taskLabel">任务编号</li>
            <li class="taskInfo bgcolor-ccc">{{form.taskNo}}</li>
            <li class="taskLabel ">任务创建人</li>
            <li class="taskInfo noBorder bgcolor-ccc">{{form.createUserName}}</li>
            <li class="taskLabel">任务名称</li>
            <li class="taskInfo">{{form.name}}</li>
            <li class="taskLabel ">任务提交人</li>
            <li class="taskInfo noBorder bgcolor-ccc">{{form.commitUserName}}</li>
            <li class="taskLabel">任务类型</li>
            <li class="taskInfo">{{form.taskTypeFlows}}</li>
            <li class="taskLabel ">任务等级</li>
            <li class="taskInfo noBorder">{{form.grade == 1 ? '一般' : '紧急'}}</li>
            <li class="taskLabel">任务对象</li>
            <li class="taskInfo">{{form.taskObject}}</li>
            <li class="taskLabel ">任务对象类型</li>
            <li class="taskInfo noBorder">{{form.object1}}<span v-if="form.object2">,</span>{{form.object2}}<span
              v-if="form.object3">,</span>{{form.object3}}
            </li>
            <li class="taskLabel">值班人员</li>
            <li class="taskLong">{{form.dutyFullname}}</li>
            <li class="taskLabel height68 line-height-68">任务概要</li>
            <li class="taskLong height68" ref="task1">{{form.summary}}</li>
            <li class="taskLabel height68 line-height-68">参考附件</li>
            <li class="taskLong height68" ref="task2">
              <div class="annex-width">
                <!--<a class="annex-div" v-for='(item,index) in bgImg1' target='_blank' :href="item" download="">-->
                <!--<img :src="item"/>-->
                <!--</a>-->
                <a class="annex-div file-div" v-for='(item,index) in fileImg1' target='_blank'
                   :href="item" download="item">
                  <div>{{item.substring(item.lastIndexOf('/') + 1)}}</div>
                </a>
              </div>
            </li>
            <li class="taskLabel">专项</li>
            <li class="taskLong">
              <el-checkbox v-model="form.special" disabled class="task-check">是</el-checkbox>
              <el-col :span="6" v-for="(item,index) in specialItem" :key='index' class="copyli">
                {{item}}
              </el-col>
            </li>
            <li class="taskLabel">任务地点</li>
            <li class="taskInfo">{{form.location}}</li>
            <li class="taskLabel ">完成期限</li>
            <li class="taskInfo noBorder">{{form.deadline ? $m(form.deadline).format('YYYY-MM-DD HH:mm:ss') : ''}}</li>
            <li class="taskLabel" v-if="form.taskNo == '201909271633010' || form.taskNo == '201909271633009'" style="line-height: 64px; border-bottom: none">机构</li>
            <li class="taskLabel" v-else>机构</li>
            <li class="taskLong">
              <div class="taskInfo" style="border-bottom: none;">{{form.organiza}}</div>
              <div>{{form.department}}</div>
            </li>
            <template v-if="form.taskNo == '201909271633010'">
              <li class="taskLabel"> </li>
              <li class="taskLong">
                <div class="taskInfo" style="border-bottom: none;">危管防污处</div>
                <div></div>
              </li>
            </template>
            <template v-if="form.taskNo == '201909271633009'">
              <li class="taskLabel"> </li>
              <li class="taskLong">
                <div class="taskInfo" style="border-bottom: none;">芝罘海事处</div>
                <div></div>
              </li>
            </template>
            <li class="task-dheight" :style="{'line-height': `${dheight}px`}">执行单元</li>
            <li class="task-border-bottom" ref='det'>
              <div v-for="(item,index) of unitlist" :key="index" class="task-height">
                <div class="task-width-200">&nbsp;{{item.fullname}}</div>
                <div class="task-width-200">&nbsp;{{item.carName}}</div>
                <div class="task-width-200">&nbsp;{{item.vehicle_name}}</div>
                <div class="task-width-200 noBorder">&nbsp;{{item.toolName}}</div>
              </div>
            </li>
            <li v-if='xiangqing' class="task-defectitem">
              <ul v-for="(item,index) in form.defectitem">
                <li class="taskLabel">缺陷项</li>
                <li class="taskInfo">{{item.defectitem}}</li>
                <li class="taskLabel">滞留缺陷</li>
                <li class="taskInfo noBorder">
                  <el-radio-group v-model="item.retention" disabled>
                    <el-radio :label='1'>是</el-radio>
                    <el-radio :label='2'>否</el-radio>
                  </el-radio-group>
                </li>
              </ul>
            </li>
            <li class="taskLabel" v-if="xiangqing">检查数量</li>
            <li class="taskInfo" v-if="xiangqing">{{form.shipCount}}</li>
            <li class="taskLabel" v-if="xiangqing">巡航里程(海里)</li>
            <li class="taskInfo noBorder" v-if="xiangqing">{{form.cruise}}</li>
            <li class="taskLabel" v-if="xiangqing">缺陷数量</li>
            <li class="taskInfo task-width-100" v-if="xiangqing">{{form.defectCount}}</li>
            <li class="taskLabel" v-if="xiangqing">滞留缺陷数量</li>
            <li class="taskLabel" v-if="xiangqing">{{form.retentionCount}}</li>
            <li class="taskLabel" v-if="xiangqing">已整改缺陷数量</li>
            <li class="taskInfo noBorder task-width-100" v-if="xiangqing">{{form.rectifyCount}}</li>
            <li class="taskLabel height68 line-height-68" v-if="xiangqing">执行情况</li>
            <li class="taskLong height68" v-if="xiangqing" ref="task3">{{form.implementation}}</li>
            <li class="taskLabel height112 line-height-112" v-if="xiangqing">处理措施</li>
            <li class="taskLong height112" style="display: flex; flex-direction: column; padding: 0" ref="task4" v-if="xiangqing">
              <div class="taskLong height68" style="line-height: 68px;">
                <el-checkbox-group v-model="punishment.measureCheck">
                  <el-row>
                    <el-col :span='4'>
                      <el-checkbox label="立案调查" :disabled='xiangqing'></el-checkbox>
                    </el-col>
                    <el-col :span='4'>
                      <el-checkbox label="行政处罚" :disabled='xiangqing'></el-checkbox>
                    </el-col>
                    <el-col :span='4'>
                      <el-checkbox label="滞留" :disabled='xiangqing'></el-checkbox>
                    </el-col>
                    <el-col :span='4'>
                      <el-checkbox label="违法记分" :disabled='xiangqing'></el-checkbox>
                    </el-col>
                    <el-col :span='4'>
                      <el-checkbox label="警示教育" :disabled='xiangqing'></el-checkbox>
                    </el-col>
                  </el-row>
                </el-checkbox-group>
<!--                <el-checkbox v-model='punishment.check1' :disabled='xiangqing' label="立案调查">立案调查</el-checkbox>-->
<!--                <el-checkbox v-model='punishment.check2' :disabled='xiangqing' label="行政处罚">行政处罚</el-checkbox>-->
                <!--<el-select v-model='punishment.select1' style="width:120px;margin:0px 10px" class="select-width-100"
                           v-if='punishment.check2' :disabled='xiangqing'>
                  <el-option v-for="it in XZCF" :key="it.id" :label="it.name" :value="it.id">
                  </el-option>
                </el-select>-->
<!--                <el-checkbox v-model='punishment.check3' :disabled='xiangqing' label="滞留">滞留</el-checkbox>-->
<!--                <el-checkbox v-model='punishment.check4' :disabled='xiangqing' label="违法记分">违法记分</el-checkbox>-->
                <!--<el-select v-model='punishment.select2' style="width:120px;margin:0px 10px" class="select-width-100"
                            :disabled='readread'>
                  <el-option v-for="it in options" :key="it" :label="it" :value="it">
                  </el-option>
                </el-select>-->
<!--                <el-checkbox v-model='punishment.check5' :disabled='xiangqing' label="警示教育">警示教育</el-checkbox>-->
                <!--<div class="punish" v-for='(item,index) in punishment' :key='index'>-->
                <!--<el-checkbox :checked='item.choose' :disabled='xiangqing'>{{item.name}}</el-checkbox>-->
                <!--<el-select v-model='item.value' class="task-select-width" :disabled='xiangqing'-->
                <!--v-if='item.choose&&item.pms.length!=0'>-->
                <!--<el-option v-for="it in item.pms" :key="it.d_id" :label="it.name" :value="it.name">-->
                <!--</el-option>-->
                <!--</el-select>-->
                <!--</div>-->
              </div>
              <div class="taskLong" style="border-bottom:0px; text-align: center;">{{punishment.textarea}}</div>
            </li>
            <li class="taskLabel height68 line-height-68" v-if="xiangqing">任务附件</li>
            <li class="taskLong height68" ref="task5" v-if="xiangqing">
              <div class="annex-width">
                <!--<a class="annex-div" v-for='(item,index) in bgImg' target='_blank' :href="item" download="">-->
                <!--<img :src="item"/>-->
                <!--</a>-->
                <a class="annex-div file-div" v-for='(item,index) in fileImg1' target='_blank'
                   :href="item" download="item">
                  <div>{{item.substring(item.lastIndexOf('/') + 1)}}</div>
                </a>
              </div>
            </li>
            <li class="taskLabel height68 line-height-68">备注</li>
            <li class="taskLong height68" ref="task6">{{form.remark}}</li>
            <li class="taskLabel height68 line-height-68" v-if="xiangqing && ducha && isSearch">任务督查</li>
            <li class="taskInfo height68 line-height-68" v-if="xiangqing && ducha && isSearch">
              <el-radio-group v-model="form.questionFlag">
                <!-- <el-radio :label="1" :disabled='!idtDetail||aadmin=="true"||form.inspectionOrNot=="1"'>有问题</el-radio>
                            <el-radio :label="2" :disabled='!idtDetail||aadmin=="true"||form.inspectionOrNot=="1"'>无问题</el-radio> -->
                <el-radio :label="1" :disabled='inspected'>有问题</el-radio>
                <el-radio :label="2" :disabled='inspected'>无问题</el-radio>
              </el-radio-group>
            </li>
            <li class="taskLabel height68 line-height-68" v-if="xiangqing && ducha && isSearch">督查内容</li>
            <li class="taskInfo noBorder height68 imp-input" v-if="xiangqing && ducha && isSearch">
              <!-- <el-input type="textarea" v-model="form.inspectionOpinion" class="width700 insIpt" :disabled='!idtDetail||aadmin=="true"||form.inspectionOrNot=="1"'></el-input> -->
              <el-input type="textarea" v-model="form.inspectionOpinion" class="width700 insIpt"
                        :disabled='inspected'></el-input>
              <!--!idtDetail||ducha==1||isDc==false-->
            </li>
            <li class="task-dheight" v-if="xiangqing && creator && isSearch" :style="{'line-height':eheight}">任务评价</li>
            <li class="task-dheight" v-if="xiangqing && !creator && evadetail.length!=0 && isSearch" :style="{'line-height':eheight}">
              任务评价
            </li>
            <li class="task-border-bottom" v-if="xiangqing && creator && isSearch" ref='det1'>
              <div class="imp" v-for='(item,index) in evadetail' :key='index'>
                <div class="imp-div">
                  <el-rate v-model.number="item.taskEvaluation" :texts="texts" show-text disabled></el-rate>
                  <div class="imp-info">{{item.implementation}}</div>
                </div>
                <div class="imp-name">
                  <span style='font-size: 12px;color:#999'>评价人: {{item.userName}} &nbsp;&nbsp; 评价时间: {{ $m(item.createTime).format('YYYY-MM-DD HH:mm:ss') }}</span>
                </div>
              </div>
              <div class="imp-input" v-if='creator' style="margin-top: 10px;">
                <el-rate v-model.number="form.taskEvaluation" :texts="texts" show-text></el-rate>
                <textarea class="width700" maxlength="150" v-model="form.implementationText" style="margin-top: 10px;"></textarea>
              </div>
            </li>
            <li class="task-border-bottom" v-if="xiangqing && !creator && evadetail.length!=0 && isSearch" ref='det1'>
              <div class="imp" v-for='(item,index) in evadetail' :key='index'>
                <div class="imp-div">
                  <el-rate v-model.number="item.taskEvaluation" :texts="texts" show-text disabled></el-rate>
                  <div class="imp-info">{{item.implementation}}</div>
                </div>
                <div class="imp-name">
                  <span style='font-size: 12px;color:#999'>评价人: {{item.userName}} &nbsp;&nbsp; 评价时间: {{ $m(item.createTime).format('YYYY-MM-DD HH:mm:ss') }}</span>
                </div>
              </div>
            </li>
          </ul>
        </div>
      </div>
      <span slot="footer" class="dialog-footer" v-show="!isprint">
      <el-button type="primary" @click="pingjia" class="sure" v-if="creator && isSearch">评价</el-button>
        <!-- <el-button type="primary" @click="sure" class="sure" v-if="org_id!=44&&idtDetail&&aadmin=='false'&&form.inspectionOrNot=='2'">督查</el-button> -->
      <el-button type="primary" @click="sure" class="sure" v-if="xiangqing && !inspected && ducha && isSearch">督查</el-button>
      <el-button type="primary" @click="print" class="sure" v-if="xiangqing">打印</el-button>
      <el-button type="primary" @click="getPdf('督查')" class="sure" v-if="inspected">下载</el-button>
      <el-button @click="closebtn1" class="cancel">关闭</el-button>
    </span>
<!--      <el-dialog ref="dialog" title="" :visible.sync="successDialog" width="30%" center append-to-body-->
<!--                 class="successDialog">-->
<!--        <p style="text-align: center;">您成功对本次任务进行了督查</p>-->
<!--        <span slot="footer" class="dialog-footer">-->
<!--			<el-button type="primary" @click="closebtn" class="successbtn">关闭 {{timer}}s</el-button>-->
<!--		</span>-->
<!--      </el-dialog>-->

<!--      <el-dialog ref="dialog" title="" :visible.sync="videoDialog" width="80%" center append-to-body-->
<!--                 class="videoDialog">-->
<!--        <div class="contant">-->
<!--          <video autoplay width="100%" height="90%" controls :src="videoSrc"></video>-->
<!--        </div>-->
<!--      </el-dialog>-->
    </div>
  </el-dialog>
</template>
<script>
  import dictService from '@/services/DictionaryService.js'
  import taskService from '@/services/TaskService.js'
  import plansService from '@/services/PlansService.js'
  import taskObjectService from '@/services/TaskObjectService'
  import taskTypeService from '@/services/TaskTypeService'
  import * as sysUserService from '@/services/SysUserService'
  import * as organizationService from '@/services/OrganizationService'
  import TaskLeaderService from '@/services/TaskLeaderService.js'

  export default {
    // props: ['taskDetail', 'pageType', 'detailType'],
    data: function () {
      return {
        successDialog: false,
        labelPosition: 'right',
        htmlTitle: '任务详情',
        timer: 3,
        evaluate: false,
        form: {
          commitUserName: '',
          organiza: '',
          createTime: '',
          sendTime: '',
          taskObject: '',
          summary: '',
          taskNo: '',
          name: '',
          type1: '',
          type2: '',
          type3: '',
          object1: '',
          object2: '',
          object3: '',
          outline: '',
          special: false,
          distribute: '',
          distributeSecond: '',
          grade: '',
          location: '',
          deadline: '',
          remark: '',
          unit: [{
            person: '',
            carrier: '',
            vehicle: '',
            tool: ''
          }],
          typeName: '',
          createUserName: '',
          endTime: '',
          taskType: [{type1: '', type2: '', type3: ''}],
          taskTypeFlows: '',
          urlFile: [],
          questionFlag: 1,
          finishTime: '',
          taskDefect: 3, // 任务评星
          taskEvaluation: 0,
          implementationText: ''
        },
        options: ['1分', '2分', '3分', '4分', '5分', '6分', '7分', '8分', '9分', '10分', '11分', '12分'],
        // form: {
        //   taskNo: '',
        //   name: '',
        //   typefirst_name: '',
        //   typesecond_name: '',
        //   area: '',//
        //   outline: '',
        //   is_examine: '',
        //   distribu_name: '',
        //   grade_name: '',
        //   location: '',
        //   unit_people: '',
        //   unit_carrier: '',
        //   unit_tool: '',
        //
        //   deadline: '',
        //   defectitem: '',
        //   url: '',
        //   inspectionOrNot: '',
        //   inspectionOpinion: '',
        //
        //   special: false,
        //   remarks: '',
        //   treatmentmeas: '',
        //   othercases: '',
        //   task_final: '',
        //   ship_numbers: '',
        //   cruise: '',
        //   pf_date: '',
        //   task_date: '',
        // },
        unitlist: [{
          fullname: '',
          carName: '',
          toolName: '',
          vehicle_name: ''
        }],
        ducha: false,
        aadmin: false,
        texts: ['任务执行非常差', '任务执行差', '任务完成合格', '任务完成良好', '任务完成非常好'],
        idtDetail: false,
        searchDetail: true,
        specialList: [],
        specialArr: [],
        specialItem: [],
        creator: false,
        yipingjia: false,
        ttimer: {},
        isprint: false,
        defectitem: [],
        xiangqing: false,
        // xzcf: false,
        wfjf: false,
        value: '',
        value1: '',
        org_id: '',
        punishment: [],
        evadetail: [],
        bgImg: [],
        fileImg: [],
        bgImg1: [],
        fileImg1: [],
        XZCF: [],
        plans: [],
        dheight: 34,
        eheight: '134px',
        video: [],
        videoSrc: '',
        videoDialog: false,
        inspected: false,
        isDc: false,
        childList: [{
          taskEvaluation: 3,
          implementation: '',
        }],
        taskType: [],
        taskObjectType: [],
        sysUser: [],
        organization: [],
          isSearch: true
      }
    },
    methods: {
      async getSelect() {
        await taskTypeService.search().then(res => {
          this.taskType = res
        })
        await organizationService.findAll().then(async res => {
          this.organization = res.data
        })
        await taskObjectService.search().then(res => {
          this.taskObjectType = res
        })
        await sysUserService.findAll().then(res => {
          this.sysUser = res.data
        })

      },
      async showDetail() {
        if (this.$route.params.pageType == 'search') {
          this.isSearch = false
          this.xiangqing = true
        } else if (this.$route.params.pageType == 'supervision') {
          this.xiangqing = true
          if (this.$route.params.detailType == true) {
            this.inspected = true
          }
        }
        let data = this.$route.params.data
        for (let key in data) {
          if (key == 'id') {
            this.detailId = data[key]
          } else if (key == 'createTime' && data[key]) {
            this.createTime = data[key]
            this.form.createTime = this.$m(data[key]).format('YYYY-MM-DD')
          } else if (key == 'sendTime' && data[key]) {
              this.form.sendTime = this.$m(data[key]).format('YYYY-MM-DD')
          } else if (key == 'finishTime' && data[key]) {
              this.form.finishTime = this.$m(data[key]).format('YYYY-MM-DD')
          } else if (key == 'commitUserId' && data[key]) {
              let userInfo = this.sysUser.find(fil => {
                  return fil.id == data[key]
              })
              if (userInfo) this.form.commitUserName = userInfo.name
          } else if (key == 'taskLeaders' && data[key]) {
              this.evadetail = data[key]
          } else if (key == 'taskUsers' && data[key]) {
            data.taskUsers.forEach((item, index) => {
              if (index > 0) {
                this.unitlist.push({fullname: '', carName: '', toolName: '', vehicle_name: ''})
                this.dheight += 35
              }
              let user = this.sysUser.find(fil => {
                return fil.id == item.userId
              })
              if (user) this.unitlist[index].fullname = user.fullname
            })

          } else if (key == 'taskTypeFlows' && data[key]) {
            let arr = await data[key].map(item => {
              return {type1: item.type1, type2: item.type2, type3: item.type3}
            })
            let task = []
            await arr.forEach((item, index) => {
              if (item.type1) {
                let obj1 = this.taskType.find(fin => {
                  return fin.id == item.type1
                })
                  task[index] = obj1 ? obj1.name : ''
                if (obj1 && obj1.subset) {
                  let obj2 = obj1.subset.find(fin => {
                    return fin.id == item.type2
                  })
                    task[index] = obj2 ? obj2.name : ''
                  if (obj2 && obj2.subset && item.type2) {
                    let obj3 = obj2.subset.find(fin => {
                      return fin.id == item.type3
                    })
                    if (obj3 && item.type3) {
                      task[index] = obj3.name
                    }
                  }
                }
              }
            })
            this.form.taskTypeFlows = task.join(',')
          } else if (key == 'organiza' && data[key]) {
            if(data[key].level == 2){
              // parentId
              let org = this.organization.find(fin => {
                return fin.id == data[key].parentId
              })
              this.form.organiza = org.name
              this.form.department = data[key].name
            }else{
              this.form.organiza = data[key].name
            }
          } else if (key == 'urlFile' && data[key]) {
            this.fileImg1 = data[key].split(',')
          } else if ((key == 'object1' || key == 'object2' || key == 'object3') && data[key]) {
            let obj, obj2, obj3
            obj = this.taskObjectType.find(item => {
              return item.id == data.object1
            })
            if (obj) {
              this.form.object1 = obj.taskname
            }
            if (obj && key == 'object2' && obj.subset) {
              obj2 = obj.subset.find(item => {
                return item.id == data.object2
              })
              this.form.object2 = obj2.taskname
              if (obj2 && key == 'object3' && obj2.subset) {
                obj3 = obj2.subset.find(item => {
                  return item.id == data.object3
                })
                this.form.object3 = obj3.taskname
              }
            }
          } else if (key == 'special' && data[key]) {
            if (data[key]) {
              this.form.special = true
            } else {
              this.form.special = false
            }
            let arr = data[key].split(',')
            arr.forEach(async item => {
              let obj = await this.plans.find(fin => {
                return fin.id == item
              })
              if (obj) this.specialItem.push(obj.name)
            })
          } else if (key == 'finalResult' && data[key]) {
            let list = JSON.parse(data[key])
            if (list) this.punishment = list
          } else if (key == 'questionFlag') {
            this.form.questionFlag = data[key] ? 2 : 1
          } else if (key == 'taskEvaluation' && data[key]) {
            this.form.taskEvaluation = data[key].split("__")[0]
            this.form.taskDefect = data[key].split("__")[1] * 1
          } else if (key == 'superviseResult' && data[key]) {
            this.form.inspectionOpinion = data[key]
          } else if (data[key]) {
            this.form[key] = data[key]
          }
        }
      },
      sure() {
        //form.questions // questionFlag
        //form.inspectionOpinion // superviseResult
        taskService.update(
          {
            id: this.detailId,
            questionFlag: this.form.questions == 1 ? true : false,
            superviseResult: this.form.inspectionOpinion,
          }, 8).then(res => {

          if (res) {
            this.$message({
              type: 'success',
              message: '督查成功'
            })
            this.successDialog = false
            this.$emit('close')
          }
        })
      },
      pingjia() {
          let obj = {
              task: {
                  id: this.detailId
              },
              taskEvaluation: this.form.taskEvaluation,
              implementation: this.form.implementationText
          }
          TaskLeaderService.saveLeader(obj).then(res => {
              if (res) {
                  this.$message({
                      type: 'success',
                      message: '评价成功'
                  })
                  this.successDialog = false
                  this.$emit('close')
              }
          })
      },
      closebtn() {
        this.$emit('close')
        clearInterval(this.ttimer)
        this.timer = 3
      },
      closebtn1() {
        this.successDialog = false
        this.$emit('close')

      },
      print() {
        for (var i of document.head.getElementsByTagName('style')) {
          if (i.media == 'print') {
            i.innerHTML = '@page { size: portrait; }'
            // i.innerHTML ='@page { size: landscape; }';
          }
        }
        this.$emit('changeWidth', '790px')
        this.isprint = true
        document.getElementById('app').style.display = 'none'
        setTimeout(() => {
          window.print()
          this.$emit('changeWidth', '80%')
          this.isprint = false
          document.getElementById('app').style.display = 'block'
        }, 200)
      },
      videoPlay(id) {
        this.videoSrc = this.video[id]
        this.videoDialog = true
      }
    },
    async created() {
      this.successDialog = true
      this.org_id = localStorage.getItem('org_id')
      this.aadmin = localStorage.getItem('admin')
      this.cuId = localStorage.getItem('cu_id')

      this.bgImg = []
      this.fileImg = []
      this.bgImg1 = []
      this.fileImg1 = []
      this.video = []
      let detailData = this.$route.params.data
      // if (this.$profile.level == 3 || this.$profile.level == 4) {
      //     this.creator = true
      // } else if (this.$profile.level == 2 && detailData.managementUnit == this.$profile.organiza.id) {
      //     this.creator = true
      // } else if (this.$profile.level == 1 && detailData.enforcementBrigade == this.$profile.organiza.id) {
      //     this.creator = true
      // } else if (detailData.createUserId == this.$profile.id) {
      //     this.creator = true
      // } else {
      //     this.creator = false
      // }
      if (!detailData.finishTime) {
          this.creator = false
      } else {
          this.creator = true
          this.ducha = true
      }
      const loading = this.$loading({
          lock: true,
          text: 'Loading',
          spinner: 'el-icon-loading',
          background: 'rgba(0, 0, 0, 0.7)'
      })
      plansService.searchAll().then(res => {
        this.plans = res
      })
      dictService.find('XZCF').then(res => {
        this.XZCF = res
      })
      await this.getSelect()
      await this.showDetail()
      this.eheight = this.$refs.det1 ? this.$refs.det1.getBoundingClientRect().height - 1 + 'px' : '134px'
        this.$refs.task1.previousSibling.previousElementSibling.style.height = this.$refs.task1.getBoundingClientRect().height - 1 + 'px'
        this.$refs.task2.previousSibling.previousElementSibling.style.height = this.$refs.task2.getBoundingClientRect().height - 1 + 'px'
        this.$refs.task3.previousSibling.previousElementSibling.style.height = this.$refs.task3.getBoundingClientRect().height - 1 + 'px'
        this.$refs.task4.previousSibling.previousElementSibling.style.height = this.$refs.task4.getBoundingClientRect().height - 1 + 'px'
        this.$refs.task5.previousSibling.previousElementSibling.style.height = this.$refs.task5.getBoundingClientRect().height - 1 + 'px'
        this.$refs.task6.previousSibling.previousElementSibling.style.height = this.$refs.task6.getBoundingClientRect().height - 1 + 'px'
      loading.close()
    }
  }
</script>

<style lang="scss" src="./TaskDetail.scss"></style>
